package com.j2eefast.flowable.bpm.service;


import com.j2eefast.flowable.bpm.entity.bpmCrmTemptagwarehouseEntity;
import com.j2eefast.flowable.bpm.mapper.bpmCrmTemptagwarehouseMapper;
import com.j2eefast.common.core.mutidatasource.annotaion.DataSource;
import com.j2eefast.common.core.page.Query;
import com.j2eefast.common.core.utils.PageUtil;
import com.j2eefast.common.core.utils.ToolUtil;
import com.j2eefast.framework.utils.Constant;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import javax.annotation.Resource;
import org.springframework.transaction.annotation.Transactional;
import java.util.Map;
import java.util.Arrays;
/**
 *
 * 临牌仓库Service接口
 * @author: yhli
 * @date 2020-06-30 14:20
 */
@Service
public class bpmCrmTemptagwarehouseService extends ServiceImpl<bpmCrmTemptagwarehouseMapper,bpmCrmTemptagwarehouseEntity> {

	@Resource
	private bpmCrmTemptagwarehouseMapper bpmCrmTemptagwarehouseMapper;

	/**
	 * mybaitis-plus 页面分页查询
     */
    @DataSource(name="FLOWABLE")
	public PageUtil findPage(Map<String, Object> params) {
        QueryWrapper<bpmCrmTemptagwarehouseEntity> queryWrapper = new QueryWrapper<bpmCrmTemptagwarehouseEntity>();
           String createBy = (String) params.get("createBy");
         queryWrapper.eq(ToolUtil.isNotEmpty(createBy), "create_by", createBy);
                         String carNumber = (String) params.get("carNumber");
         queryWrapper.eq(ToolUtil.isNotEmpty(carNumber), "car_number", carNumber);
          String validateStartTime = (String) params.get("validateStartTime");
         queryWrapper.eq(ToolUtil.isNotEmpty(validateStartTime), "validate_start_time", validateStartTime);
          String validateEndTime = (String) params.get("validateEndTime");
         queryWrapper.eq(ToolUtil.isNotEmpty(validateEndTime), "validate_end_time", validateEndTime);
     		Page<bpmCrmTemptagwarehouseEntity> page = bpmCrmTemptagwarehouseMapper.selectPage(new Query<bpmCrmTemptagwarehouseEntity>(params).getPage(), queryWrapper);
		return new PageUtil(page);
    }

    /**
     * 自定义分页查询，含关联实体对像
     */
    @DataSource(name="FLOWABLE")
	public PageUtil findPage(Map<String, Object> params,bpmCrmTemptagwarehouseEntity bpmCrmTemptagwarehouseEntity) {
		Page<bpmCrmTemptagwarehouseEntity> page = bpmCrmTemptagwarehouseMapper.findPage(new Query<bpmCrmTemptagwarehouseEntity>(params).getPage(), bpmCrmTemptagwarehouseEntity,(String) params.get(Constant.SQL_FILTER))  ;
		return new PageUtil(page);
	}
	/**
     * 批量删除
     */
    @DataSource(name="FLOWABLE")
	@Transactional(rollbackFor = Exception.class)
	public boolean deletebpmCrmTemptagwarehouseByIds(String[] ids) {
		return removeByIds(Arrays.asList(ids));
	}

	/**
     * 单个删除
     */
    @DataSource(name="FLOWABLE")
	public boolean deletebpmCrmTemptagwarehouseById(String id) {
		return removeById(id);
	}

	/**
     * 保存
     */
    @DataSource(name="FLOWABLE")
	public boolean savebpmCrmTemptagwarehouse(bpmCrmTemptagwarehouseEntity bpmCrmTemptagwarehouse){
        return save(bpmCrmTemptagwarehouse);
    }

	/**
     * 修改根居ID
     */
    @DataSource(name="FLOWABLE")
	public boolean updatebpmCrmTemptagwarehouseById(bpmCrmTemptagwarehouseEntity bpmCrmTemptagwarehouse) {
		return updateById(bpmCrmTemptagwarehouse);
	}

	/**
     * 根居ID获取对象
     */
    @DataSource(name="FLOWABLE")
	public bpmCrmTemptagwarehouseEntity getbpmCrmTemptagwarehouseById(String id){
		return getById(id);
	}
}
